/*
 * PropertiesFrame.java
 *
 * Created on March 2, 2005, 9:44 AM
 */

package com.bff.slimserver.musicjukebox.ui.settings;

import com.bff.bjj.ui.component.ColorProperties;
import com.bff.bjj.ui.component.BJJPanel;
import com.bff.bjj.ui.component.BJJButton;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JOptionPane;


/**
 *
 * @author  findeisb
 */
public class PropertiesFrame extends javax.swing.JFrame {
    private boolean firstTime;
    
    /** Creates new form PropertiesFrame */
    public PropertiesFrame() {
        this(false);
    }
    
    public PropertiesFrame(boolean firstTime) {
        this.firstTime = firstTime;
        
        initComponents();

        setSize(1000, 800);
        
        //set frame nicely in screen
        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        int heightScreen = d.height / 2;
        int widthScreen = d.width / 2;

        setLocation(widthScreen - (int)(getWidth()/2), heightScreen - (int)(getHeight()/2));

        setColors();
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        inquiryPanel = new SettingsPanel(firstTime);
        btnPanel = new BJJPanel();
        cancelButton = new BJJButton();
        titlePanel = new BJJPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Settings");
        getContentPane().add(inquiryPanel, java.awt.BorderLayout.CENTER);

        cancelButton.setText("Cancel");
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        btnPanel.add(cancelButton);

        getContentPane().add(btnPanel, java.awt.BorderLayout.SOUTH);

        titlePanel.setLayout(new java.awt.BorderLayout());

        jLabel1.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 18));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Music Jukebox Settings");
        jLabel1.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
        titlePanel.add(jLabel1, java.awt.BorderLayout.NORTH);

        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Please Enter Settings");
        titlePanel.add(jLabel2, java.awt.BorderLayout.SOUTH);

        getContentPane().add(titlePanel, java.awt.BorderLayout.NORTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void settingsPanelComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_settingsPanelComponentResized
        this.pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
        this.repaint();
    }//GEN-LAST:event_settingsPanelComponentResized
    
    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        int n = JOptionPane.showConfirmDialog(this,
                "Are You Sure You Want to Cancel Setup?",
                "Cancel Setup",
                JOptionPane.YES_NO_OPTION);
        
        if(n==JOptionPane.YES_OPTION) {
            this.dispose();
            System.exit(0);
        }
    }//GEN-LAST:event_cancelButtonActionPerformed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel btnPanel;
    private javax.swing.JButton cancelButton;
    private javax.swing.JPanel inquiryPanel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel titlePanel;
    // End of variables declaration//GEN-END:variables
    
    protected void setColors() {
        setBackground(ColorProperties.PANEL_BACKGROUND);
    }
}
